var supplier={};
var editFlag=0;
var index="";
var flag=1;
var supplierId="";
$(document).ready(function() {
    if(!isNULL(GetQueryString("supplierId"))){
        supplierId=GetQueryString("supplierId");
        editFlag=1;
        var supplierMsg=getStorJson("supplierMsg");
        edit(JSON.parse(supplierMsg));
    }
});
//保存
$("#saveSupplier").click(function(){
    submit();
});
//编辑banner
function edit(supplierMsg){
    $("#platformPeopleName").val(supplierMsg.platformPeopleName);
    $("#supplierName").val(supplierMsg.supplierName);
    $("#supplierPeopleName").val(supplierMsg.supplierPeopleName);
    $("#supplierPeoplePhone").val(supplierMsg.supplierPeoplePhone);
    $("#supplierAdress").val(supplierMsg.supplierAdress);
    $("#supplierFinanceName").val(supplierMsg.supplierFinanceName);
    $("#supplierBankAccount").val(supplierMsg.supplierBankAccount);
    $("#supplierBankName").val(supplierMsg.supplierBankName);
}
//统计输入框信息
function statics(){
    supplier={};
    supplier.platformPeopleName=$("#platformPeopleName").val();
    supplier.supplierName=$("#supplierName").val();
    supplier.supplierPeopleName=$("#supplierPeopleName").val();
    supplier.supplierPeoplePhone=$("#supplierPeoplePhone").val();
    supplier.supplierAdress=$("#supplierAdress").val();
    supplier.supplierFinanceName=$("#supplierFinanceName").val();
    supplier.supplierBankAccount=$("#supplierBankAccount").val();
    supplier.supplierBankName=$("#supplierBankName").val();
}
//添加banner
function submit(){
    if(flag!==1){
        layer.msg("请不要重复提交");
        return;
    }
    flag=0;
    statics();
    saveSupplier(supplier,supplierId);
}
//保存接口
function saveSupplier(supplier,supplierId){
    ajax({
        url:"goodsSupplier/addOrUpdate",
        data:{
            supplierId:supplierId,
            supplierName:supplier.supplierName,
            platformPeopleName:supplier.platformPeopleName,
            supplierPeopleName:supplier.supplierPeopleName,
            supplierPeoplePhone:supplier.supplierPeoplePhone,
            supplierAdress:supplier.supplierAdress,
            supplierFinanceName:supplier.supplierFinanceName,
            supplierBankName:supplier.supplierBankName,
            supplierBankAccount:supplier.supplierBankAccount
        },
        success:function(data){
            
            if(data.success){
                layer.msg(data.message);
                window.location.href="goodsSupplier.html";
            }else{
                layer.msg(data.message);
                flag=1;
            }
        }
    });
}